package com.lcz.authority.common.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.zhou.starter.jpacomment.annotation.ColumnComment;
import lombok.Data;

import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author lcz
 * @desc Entity基类
 * @mail lcz_0130@163.com
 * @date 2024/05/06
 */
@Data
@MappedSuperclass
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;


    @TableField(fill = FieldFill.INSERT)
    @ColumnComment("创建时间")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT)
    @ColumnComment("创建人")
    private String createUser;

    @TableField(fill = FieldFill.UPDATE)
    @ColumnComment("更新时间")
    private Date updateTime;

    //    @TableField(fill = FieldFill.UPDATE)
    @ColumnComment("更新人")
    private String updateUser;

    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    @JsonIgnore
    @ColumnComment("删除标记")
    private Integer delFlag;

    @TableField(exist = false)
    @Transient
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params = new HashMap<>();

    public static class IsDelFlag {
        /**
         * 0：正常
         */
        public static final int NO = 0;
        /**
         * 1：删除
         */
        public static final int YES = 1;
    }
}
